home *** CD-ROM | disk | FTP | other *** search
/ Suzy B Software 2 / Suzy B Software CD-ROM 2 (1994).iso / extras / programm / gemfsc20 / gemfsc20.lzh / GEMFUNCS / APLXINIT.C < prev    next >
C/C++ Source or Header  |  1993-03-20  |  5KB  |  125 lines

  1. /**************************************************************************
  2.  * APLXINIT.C - aplx_init(), apl_xexit() functions; new global data items.
  3.  *************************************************************************/
  4.  
  5. #include "gemfintl.h"
  6.  
  7. #undef appl_init  /* undo the remapping macros that gemfintl.h sets up to */
  8. #undef appl_exit  /* get applications into here; we need The Real Thing.  */
  9.  
  10. void (*_AesVCleanup) __PROTO((void)) = NULL; /* var shared with APLVWORK.C */
  11.  
  12. /*-------------------------------------------------------------------------
  13.  * new global data items (for use in gemfast utils and by application)...
  14.  *-----------------------------------------------------------------------*/
  15.  
  16. unsigned short       gl_grfhandle=0;    /* global physical VDI handle         */
  17.  
  18. unsigned short       gl_wchar;        /* width of a character              */
  19. unsigned short       gl_w2char;        /* width of a character  / 2         */
  20. unsigned short       gl_w4char;        /* width of a character  / 4         */
  21. unsigned short       gl_w8char;        /* width of a character  / 8         */
  22.  
  23. unsigned short       gl_hchar;        /* height of a character             */
  24. unsigned short       gl_h2char;        /* height of a character / 2         */
  25. unsigned short       gl_h4char;        /* height of a character / 4         */
  26. unsigned short       gl_h8char;        /* height of a character / 8         */
  27.  
  28. unsigned short       gl_wbox;         /* width of a boxchar                 */
  29. unsigned short       gl_w2box;        /* width of a boxchar     / 2         */
  30. unsigned short       gl_w4box;        /* width of a boxchar     / 4         */
  31. unsigned short       gl_w8box;        /* width of a boxchar     / 8         */
  32.  
  33. unsigned short       gl_hbox;         /* height of a boxchar                 */
  34. unsigned short       gl_h2box;        /* height of a boxchar     / 2         */
  35. unsigned short       gl_h4box;        /* height of a boxchar     / 4         */
  36. unsigned short       gl_h8box;        /* height of a boxchar     / 8         */
  37.  
  38. GRECT    gl_rwdesk;        /* coordinates of work area of the desktop         */
  39. GRECT    gl_rfscrn;        /* coordinates of the full screen                 */
  40.  
  41. /*-------------------------------------------------------------------------
  42.  * apl_cleanup() - Clean up transient resources we've aquired.
  43.  *
  44.  *     For now, that means close the shared VDI workstation.    We do this
  45.  *     by calling through the vdi cleanup vector if it is non-NULL.  if
  46.  *     the shared workstation was ever opened, the vector is set by the
  47.  *     apl_vopen() routine to point to the closer routine.  Since the
  48.  *     actual vector variable lives in this module, and starts out as NULL,
  49.  *     we avoid making a direct call to the vdi cleanup, and thus we avoid
  50.  *     linking all the vdi groodah into a program that doesn't need it.
  51.  *
  52.  *     Right now, we don't use the options value.  Someday we are going to
  53.  *     have transient and permenant resources, and the flag will indicate
  54.  *     whether the permenant resources are also to be cleaned up.
  55.  *-----------------------------------------------------------------------*/
  56.  
  57. void apl_cleanup(options)
  58.     short options;
  59. {
  60.     (void)options;
  61.     if (_AesVCleanup != NULL) {
  62.         (*_AesVCleanup)();
  63.     }
  64. }
  65.  
  66. /*-------------------------------------------------------------------------
  67.  * _ApXinit() - internal routine to init new global data items.
  68.  *
  69.  *     this is called from apl_xinit(), below, and also from apl_vopen().
  70.  *     the latter is a just-in-case call, on the off chance that the caller
  71.  *     never came through the extended init in the first place.
  72.  *-----------------------------------------------------------------------*/
  73.  
  74. void _ApXinit()
  75. {
  76.     gl_grfhandle = graf_handle(&gl_wchar, &gl_hchar, &gl_wbox, &gl_hbox);
  77.  
  78.     gl_w2char = gl_wchar / 2;    /* the library routines do a lot of        */
  79.     gl_w4char = gl_wchar / 4;    /* rez-independant things based on halves, */
  80.     gl_w8char = gl_wchar / 8;    /* quarters, and eighths of a char.        */
  81.  
  82.     gl_h2char = gl_hchar / 2;
  83.     gl_h4char = gl_hchar / 4;
  84.     gl_h8char = gl_hchar / 8;
  85.  
  86.     gl_w2box  = gl_wbox / 2;
  87.     gl_w4box  = gl_wbox / 4;
  88.     gl_w8box  = gl_wbox / 8;
  89.  
  90.     gl_h2box  = gl_hbox / 2;
  91.     gl_h4box  = gl_hbox / 4;
  92.     gl_h8box  = gl_hbox / 8;
  93.  
  94.     winx_get(0, WF_WORKXYWH, &gl_rwdesk);
  95.     gl_rfscrn.g_x = gl_rfscrn.g_y = 0;
  96.     gl_rfscrn.g_w = gl_rwdesk.g_x + gl_rwdesk.g_w;
  97.     gl_rfscrn.g_h = gl_rwdesk.g_y + gl_rwdesk.g_h;
  98. }
  99.  
  100. /*-------------------------------------------------------------------------
  101.  * apl_xinit() - Extended init.  Does appl_init() plus fills in new global
  102.  *                 data items.  A GEMFAST.H macro makes this routine get
  103.  *                 invoked when the application calls appl_init().
  104.  *-----------------------------------------------------------------------*/
  105.  
  106. short apl_xinit()
  107. {
  108.     if (0 <= appl_init()) {
  109.         _ApXinit();
  110.     }
  111.     return gl_apid;
  112. }
  113.  
  114. /*-------------------------------------------------------------------------
  115.  * apl_xexit() - extended exit. call the cleanup routine, then appl_exit().
  116.  *-----------------------------------------------------------------------*/
  117.  
  118. void apl_xexit()
  119. {
  120.     apl_cleanup(APL_RTRANSIENT|APL_RPERMANENT);
  121.     appl_exit();
  122. }
  123.  
  124.  
  125.